<template>
  <div class="uploading-info">
    <timer />
    <div class="info">
      <template v-if="true">
        <span>正在上传：</span>
        <span class="upload-file-name">{{ uploadFileName }}</span>
        <span>，</span>
      </template>
      <template v-if="queueLeftCount">
        <span>有</span>
        <span class="queue-left-count">{{ queueLeftCount }}</span>
        <span>个文件等待中，</span>
      </template>
      <template v-if="errorCount">
        <span>上传失败</span>
        <span class="error-count">{{ errorCount }}</span>
        <span>个，</span>
      </template>
      <span>点击</span>
      <span class="see" @click="$emit('on-see')">查看</span>
      <span>进度</span>
    </div>
  </div>
</template>

<script>
import Timer from './timer'

export default {
  components: {
    Timer
  },
  props: ['uploadList', 'uploadFile'],

  computed: {
    uploadFileName() {
      return this.uploadFile.file && this.uploadFile.file.name;
    },
    queueLeftCount() {
      return this.uploadList.length === 0 ? 0 : this.uploadList.length - 1;
    },

    errorCount() {
      return this.uploadList.filter(item => item.status === 3).length;
    }
  }
}
</script>

<style lang="scss" scoped>
.uploading-info {
  padding: 0 20px;
  margin: 0 -20px;
  height: 26px;
  background-color: #CDDEF6;
  display: flex;
  align-items: center;

  .info {
    padding-left: 10px;
    display: flex;
    line-height: 20px;
    font-size: 12px;
    user-select: none;

    .upload-file-name {
      max-width: 450px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .queue-left-count {
      font-weight: bold;
      color: #5293F5;
    }
    .error-count {
      font-weight: bold;
      color: #FF7982;
    }
    .see {
      font-weight: bold;
      color: #5293F5;
      cursor: pointer;
    }
  }
}
</style>